

<!--<!DOCTYPE HTML>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <title>ueditor demo</title>
</head>-->

<!--<a href="#/layui/meetList" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: 20px 0 0 100px;">
  <i class="layui-icon">&#xe65c;</i>
</a>-->

<form action="" class="layui-form">
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-row">
		    <div class="layui-col-xs12">
		    	<div class="layui-card-header"><h2>添加会议</h2>
		      	</div>
		      	<div class="layui-card-body">
		      
		      	<!--<div class="layui-card-body">-->
		      		<div class="layui-form-item">
		      			<div class="layui-form-label">会议名称：<span class="haveTo">*</span></div>
		      			<div class="layui-input-block">
		      				<input type="text" name="meetName" lay-verify="required" class="layui-input meetName" >
		      			</div>
		      		</div>
		      		<div class="layui-form-item">
		      			<div class="layui-form-label">开始时间：<span class="haveTo">*</span></div>
		      			<div class="layui-input-block">
		      				<input type="text" lay-verify="required" class="layui-input startTime" id="dayz">
		      			</div>
		      		</div>
		      		<div class="layui-form-item" style="display: none;">
		      			<div class="layui-form-label">产品摘要：<span class="haveTo">*</span></div>
		      			<div class="layui-input-block">
		      				<textarea id="demo" class="prodInfo"></textarea>
		      			</div>
		      		</div>
		      		<div class="layui-form-item">
		      			<div class="layui-form-label">举办地址：<span class="haveTo">*</span></div>
		      			<div class="layui-input-block">
		      				<input type="text" name="addr" lay-verify="required" class="layui-input addr">   
		      			</div>
		      		</div>
		      	<!--</div>-->
		      	
		      	
		      	
		      	<!--<table class="layui-table" lay-size="lg" style="table-layout:fixed">
				      <colgroup>
					    <col width="40">
					    <col width="500">
					  </colgroup>
				      <tbody>
				      	<tr>
				      		<td>会议名称：</td>
				      		<td>
				      			<table class="layui-table " lay-size="lg" lay-skin="nob">
				      				<tbody>
				      					<tr>
				      						<td><input type="text" name="meetName" lay-verify="required" class="layui-input meetName input33" > </td>
				      						<td><span class="haveTo">*</span></td>
				      					</tr>
				      					
				      				</tbody>
				      			</table>
				      			
				      		</td>
				      	</tr>
				      	<tr>
				      		<td>开始时间：</td>
				      		<td>
				      			<table class="layui-table"  lay-size="lg" lay-skin="nob">
				      				<tbody>
				      					<tr>
				      						<td>
				      							<div class="layui-inline"><input type="text" lay-verify="required" class="layui-input startTime" id="dayz"></div>
				      							
				      							<td><span class="haveTo">*</span></td>
				      					</tr>
				      				</tbody>
				      			</table>
				      			
				      		</td>
				      		
				      	</tr>
				      	
				      	
				      	
				      	<tr>
				      		<td>产品摘要：</td>
				      		<td class="">
				      			<textarea id="demo" class="prodInfo"></textarea>
								
				      		</td>
				      			
				      	</tr>
				      	
					  </tbody>
				      	
			      </table>-->
			      </div>	
		    </div>
		    
		    <div class="layui-col-md10">
		    	<div class="addFHBtn">
		    		<!--lay-submit-->
		    		<a class="layui-btn meetBtn layui-btn-primary" href="#/layui/meetList">返回</a>
					<button class="layui-btn confirm meetBtn" type="button" lay-submit lay-filter="queding" >确定</button>
					
				</div>
		    </div>
    	</div>
	</div>
</form>

	
      
      
<script>
	let meetName = document.querySelector(".meetName");
	let startTime = document.querySelector(".startTime");
	let prodInfo = document.querySelector(".prodInfo");
	let confirm = document.querySelector(".confirm");
	let addr = document.querySelector(".addr");
	
	layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form','route','layedit' , 'laydate'], function () {
			var $ = layui.jquery,
	      layer = layui.layer,
	      table = layui.table,
	      sidebar = layui.sidebar,
	      laydate = layui.laydate,
	      route = layui.route,
	      params = route.params(),
	      layedit = layui.layedit,
	      form = layui.form;
	      
//			     /^[0-4]*$/
	      form.verify({
			  //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
			  digital: [

				/((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)/
			    ,'请填入正确的日期格式'
			  ] 
			}); 
	      
	      let _obj = {
	      	 "Guid": "",
			  "Name": "",
			  "Address": "",
			  "StartTime": "",
			  "EndTime": "",
			  "Detail": "",
			  "CreateTime": "",
			  "CreateUser": "",
			  "ModifyUser": "",
			  "ModifyTime": ""
	      }
	      
	      laydate.render({
		    elem: '#dayz', //指定元素
		    type: 'datetime'
		  });
		
			layedit.set({
			  uploadImage: {
			    url: DBHelper.host+'/api/ImgUpload?MemLoginId=admit', //接口url
			    type: 'post'
			  }
			});
		  var index = layedit.build('demo'); //建立编辑器
		  
		  function _confirm(){
//		  	debugger
		  	_obj.Name = meetName.value;
		  	_obj.StartTime = startTime.value;
		  	_obj.Detail = layedit.getContent(index);
		  	_obj.Address = addr.value;
		  	
		  	if(params == null) {
		  		_obj.CreateTime = getNowFormatDate();
		  		_obj.CreateUser = localStorage.getItem("user");
		  		
		  		
		  		_obj.Guid = "00000000-0000-0000-0000-000000000000";
		  		console.log("_obj",_obj)
		  		
//		  		console.log("layedit.getContent(index)",layedit.getContent(index))
		  		
		  		DBHelper.Post("Admin_Xn_Meeting",_obj,function(data){
		  			let index = layer.alert("操作成功",function(){
						window.location.href="#/layui/meetList";
						layer.close(index)
					})
		  		},function(data){
		  			console.log(data)
		  		})
		  	}else{
		  		_obj.ModifyTime = getNowFormatDate();
		  		_obj.Guid = params.id;
		  		_obj.ModifyUser = localStorage.getItem("user");
		  		
//		  		console.log(_obj)
		  		
		  		DBHelper.Put("Admin_Xn_Meeting?id=" + params.id, _obj, function(data) {
		  			console.log(data)
		  			let index = layer.alert("操作成功",function(){
						window.location.href="#/layui/meetList";
						layer.close(index)
					})
					}, function(data) {
						console.log(data)
					})
		  	}
		  }
		  
		  if(params){
		  	DBHelper.Get("Admin_Xn_Meeting?id="+params.id,function(data){	
		  		console.log("data",data)
		  		_obj = data;
		  		meetName.value = data.Name;
		  		startTime.value = data.StartTime;
		  		addr.value = data.Address;
		  		layedit.setContent(index,data.Detail);
		  		
		  		
		  	})
		  }
			form.on('submit(queding)',_confirm);
		  
		console.log(1)
	})
</script>

<style scoped>
		.haveTo{
			color: red;
		}
		.meetInfo{
			position: relative;
		}
		.fr{
			float: right;
		}
		.fl{
			float: left;
		}
		.clearfix::after{
			content: "";
			display: block;
			width: 100%;
			height: 0;
			clear: both;
		}
		.meetIntro{
			position: relative;
		}
		.limit{
			position: absolute;
			bottom: 5px;
			right: 10px;
		}
      	.title{
      		margin-left: 30px;
      		margin-top: 30px;
      	}
      	.checkBtn{
      		border-radius: 5px;
      		width: 100px;
      	}
      	.listBtns{
      		display: flex;
      		justify-content: space-between;
      		width: 100%;
      	}
      	.listBtn{
      		border-radius: 5px;
      	}
      	.addFHBtn{
      		text-align: center;
      		margin-top: 20px;
      		margin-bottom: 20px;
      	}
      	/*.addFHBtn button{
      		display: inline-block;
      		width: 300px;
      	}*/
      	.meetBtn{
      		width: 150px;
      	}
      </style>